<?php
include_once '../library/config.php';
include_once '../library/popuphelper.php';
include_once '../model/stafflist.php';
include_once '../model/userlist.php';
include_once '../model/stafflistview.php';
StaffList::IsLogin();
$entity = new UserList();
$entity->request();
if ($entity['action']) {
    switch ($entity['action']) {
        case 'append':
            $entity->timestamp();
            $entity['state'] = 1;
            $entity['pwd'] = 'e10adc3949ba59abbe56e057f20f883e';
            $entity->append()->submit();
            break;
        case 'update':
            $entity->remove(array('id'));
            $entity->timestamp();
            $entity->update()->where('myid=?', array($entity['id']))->submit();
            break;
    }

    PoPupHelper::refresh();
    PoPupHelper::iframereload();
    PoPupHelper::showSucceed();
}
$entity->select()->where('myid=?', array($entity['id']))->get_first_rows();
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>后台管理系统</title>
        <link href="/css/reset.css" rel="stylesheet" type="text/css" />
        <link href="/css/layout.css" rel="stylesheet" type="text/css" />
        <link href="/css/swfupload.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form method="post"  class="labelright nomargin">
            <div class="mainwrapassist notitletoolbar">
                <table class="wp100 cellbor">
                    <tr>
                        <td class="tr w80">姓名：</td>
                        <td><input type="text" name="realname" class="w500" value="<?php echo $entity['realname']; ?>"/></td>
                    </tr>
                    <tr>
                        <td class="tr w80">性别：</td>
                        <td>
                            <select name="sex">
                                <option value="1">男</option>
                                <option value="2">女</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="tr w80">年龄：</td>
                        <td><input type="text" name="age" class="w500" value="<?php echo $entity['age']; ?>"/></td>
                    </tr>
                    <tr>
                        <td class="tr w80">账号：</td>
                        <td><input type="text" name="account" required class="w500" value="<?php echo $entity['account']; ?>"/></td>
                    </tr>
                    <tr>
                        <td class="tr w80">地址：</td>
                        <td><input type="text" name="addr" class="w500" value="<?php echo $entity['addr']; ?>"/></td>
                    </tr>
                    <tr>
                        <td class="tr w80">电话：</td>
                        <td><input type="text" name="telphone" class="w500" value="<?php echo $entity['telphone']; ?>"/></td>
                    </tr>
                </table>                
            </div>
            <div id="statusbar">
                <input type="hidden" name="action" value="<?PHP echo $entity["id"] ? "update" : "append"; ?>" />
                <button type="submit"><?PHP echo $entity["id"] ? "修改" : "增加"; ?></button>
            </div>
        </form>
        <?php include_once '../inc/js.html'; ?>
        <script src="upload.js" type="text/javascript"></script>
    </body>
</html>